package com.gome.axwl.aoc.service.impl;

import com.gome.axwl.aoc.common.util.BeanJsonUtil;
import com.gome.axwl.aoc.dao.DataDictionaryItemDao;
import com.gome.axwl.aoc.dao.DataDictionaryTypeDao;
import com.gome.axwl.aoc.entity.enums.BusinessEnum;
import com.gome.axwl.aoc.entity.enums.BusinessEnumDto;
import com.gome.axwl.aoc.entity.po.DataDictionaryItemPo;
import com.gome.axwl.aoc.service.DataDictionaryService;
import com.gome.datasource.shard.annotation.ReadDatasource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Description: 数据字典service 实现类 (量小暂时通过枚举实现，不走数据库)
 * @Auther: yinyuxin@gome.com.cn
 * @Date: 2018/7/16 10:18
 */
@Service("dataDictionaryService")
public class DataDictionaryServiceImpl implements DataDictionaryService {

    @Autowired
    private DataDictionaryItemDao dataDictionaryItemDao;
    @Autowired
    private DataDictionaryTypeDao dataDictionaryTypeDao;

    @Override
    @ReadDatasource
    public List<DataDictionaryItemPo> queryItemListByTypeCode(String typeCode) {
      //  return dataDictionaryItemDao.queryItemListByTypeCode(typeCode);
        List<BusinessEnumDto> businessEnumDtos = BusinessEnum.businessEnum2List(typeCode);
        List<DataDictionaryItemPo> data=BeanJsonUtil.listConvert(businessEnumDtos,DataDictionaryItemPo.class);
        return data;
    }

    @Override
    public String queryNameByItemCodeAndType(String itemCode, String itemType) {
        String businessEnumDtoName = BusinessEnum.queryNameByItemCodeAndType(itemCode, itemType);
        return businessEnumDtoName;
    }

   /* @Override
    @ReadDatasource
    public DataDictionaryItemPo queryItemById(Integer id) {
        return dataDictionaryItemDao.selectByPrimaryKey(id);
    }*/

}
